//
//  SISSNetworkingManager+HouseCoopProgress.m
//  SISSAPP
//
//  Created by 优房网 on 2017/8/1.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSNetworkingManager+CoopProgress.h"
#import "SISSNetworkingManager+File.h"

@implementation SISSNetworkingManager (CoopProgress)


// 4.2.3 删除房源合作进度 GET请求
- (void)deleteHouseCooperationProgressWithHouseAhcbId:(NSString *)ahcbId successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahcbId":ahcbId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_DELETE_HOUSE_COOPPROGRESS parameters:parameters success:^(id responseObject) {
        NSLog(@"4.2.3 删除房源合作进度: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.2.4 删除客源合作进度
- (void)deletePassengerCooperationProgressWithHouseAdcbId:(NSString *)adcbId successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"adcbId":adcbId
                                 };
    
    [kNetworkManager POSTWithURLString:URL_PROGRESS_DELETE_PASSENGER_COOPPROGRESS parameters:parameters success:^(id responseObject) {
        NSLog(@"4.2.4 删除客源合作进度: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.3.1 获取合作进度合作协议 GET请求
- (void)requestCooperationProgressCooperationAgreementWithAbpId:(NSString *)abpId success:(void (^)(SISSCooperationAgreementModel *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"abpId":abpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_HOUSE_COOPPROGRESS_COOPERATION_CONTRACT parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.3.1 获取合作进度合作协议: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSCooperationAgreementModel *model = [SISSCooperationAgreementModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.4.3 获取房源合作记录时间和id信息 GET请求
- (void)requestHouseCooperationProgressRecordInfoWithAhbId:(NSString *)ahbId success:(void (^)(SISSHouseCoopProgressInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"ahbId":ahbId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_HOUSE_COOPPROGRESS_INFO parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.4.3 获取房源合作记录时间和id信息: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSHouseCoopProgressInfoModel *model = [SISSHouseCoopProgressInfoModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.4.4 获取客源合作记录时间和id信息 GET请求
- (void)requestPassengerCooperationProgressRecordInfoWithAdcbId:(NSString *)adcbId success:(void (^)(SISSHouseCoopProgressInfoModel *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"adcbId":adcbId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_PASSENGER_COOPPROGRESS_INFO parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.4.4 获取客源合作记录时间和id信息: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSHouseCoopProgressInfoModel *model = [SISSHouseCoopProgressInfoModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.9.1 获取房源合作带看记录 GET请求
- (void)requestHouseCooperationTakeLookWithAcbId:(NSString *)acbId success:(void (^)(NSArray<SISSHouseCoopTakeLookModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"acbId":acbId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_HOUSE_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.9.1 获取房源合作带看记录: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *takeLookArr = [NSArray yy_modelArrayWithClass:[SISSHouseCoopTakeLookModel class] json:dataArr];
        if (successBlock) {
            successBlock(takeLookArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.9.2 获取客源合作带看记录 GET请求
- (void)requestPassengerCooperationTakeLookWithAcbId:(NSString *)acbId success:(void (^)(NSArray<SISSPassengerCoopTakeLookModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"acbId":acbId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_PASSENGER_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.9.2 获取客源合作带看记录: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *takeLookArr = [NSArray yy_modelArrayWithClass:[SISSPassengerCoopTakeLookModel class] json:dataArr];
        if (successBlock) {
            successBlock(takeLookArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];

}

// 4.10.1 获取房源合作带看记录详情 GET请求
- (void)requestHouseCooperationTakeLookDetailWithAhcrId:(NSString *)ahcrId success:(void (^)(SISSHouseTakeLookDetailModel *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"ahcrId":ahcrId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_HOUSE_COOP_TAKELOOK_DETAIL parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.10 获取房源合作带看记录详情: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSHouseTakeLookDetailModel *model = [SISSHouseTakeLookDetailModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.10.2 获取客源合作带看记录详情 GET请求
- (void)requestPassengerCooperationTakeLookDetailWithID:(NSString *)ID success:(void (^)(SISSPassengerTakeLookDetailModel *))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_PASSENGER_COOP_TAKELOOK_DETAIL parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.10.2 获取客源合作带看记录详情: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        
        SISSPassengerTakeLookDetailModel *model = [SISSPassengerTakeLookDetailModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];

}

// 4.11.1 更新房源合作带看记录状态
- (void)updateHouseCooperationTakeLookWithAhcrId:(NSString *)ahcrId state:(NSInteger)state success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahcrId":ahcrId,
                                 @"state":@(state)
                                 };
    
    [kNetworkManager POSTWithURLString:URL_PROGRESS_UPDATE_HOUSE_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        NSLog(@"4.11.1 更新房源合作带看记录状态: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.11.2 更新客源合作带看记录状态
- (void)updatePassengerCooperationTakeLookWithAdcrId:(NSString *)adcrId state:(NSInteger)state success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
        NSDictionary *parameters = @{
                                 @"adcrId":adcrId,
                                 @"state":@(state)
                                 };
    
    [kNetworkManager POSTWithURLString:URL_PROGRESS_UPDATE_PASSENGER_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        NSLog(@"4.11.2 更新客源合作带看记录状态: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.14  获取经纪人评价经纪人的评价记录 GET请求
- (void)requestCommentBrokerCommentBrokerInfoWithAcbId:(NSString *)acbId atlrId:(NSString *)atlrId commentType:(NSInteger)commentType coooperationType:(NSInteger)cooperationType success:(void (^)(NSArray<SISSCommentModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"acbId":acbId,
                                 @"atlrId":atlrId,
                                 @"comment_type":@(commentType),
                                 @"cooperation_type":@(cooperationType)
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_BROKER_COMMENT_BROKER parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.14  获取经纪人评价经纪人的评价记: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *modelArr = [NSArray yy_modelArrayWithClass:[SISSCommentModel class] json:dataArr];
        if (successBlock) {
            successBlock(modelArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.15 经纪人评价经纪
- (void)insertBrokerCommentBrokerWithParameters:(NSDictionary *)parameters success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameter = @{
                                @"spId":[SISSUserAccount shared].spId,
                                };
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
    [params addEntriesFromDictionary:parameters];
    
    [kNetworkManager POSTWithURLString:URL_PROGRESS_INSERT_BROKER_COMMENT_BROKER parameters:params success:^(id responseObject) {
        NSLog(@"4.15 经纪人评价经纪: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}


// 4.17.1  删除房源合作进度带看记录 GET请求
- (void)deleteHouseCooperationTakeLookWithTakeLookId:(NSString *)ID success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_DELETE_HOUSE_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.17.1  删除房源合作进度带看记录: responseObject-->%@",responseObject);
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock && [responseObject[@"code"] integerValue] == 200) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.17.2  删除客源合作进度带看记录
- (void)deletePassengerCooperationTakeLookWithTakeLookId:(NSString *)ID success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"id":ID
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_DELETE_PASSENGER_COOP_TAKELOOK parameters:parameters success:^(id responseObject) {
        
        NSLog(@"4.17.2  删除客源合作进度带看记录: responseObject-->%@",responseObject);
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock && [responseObject[@"code"] integerValue] == 200) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.22  获取合同文件 GET请求
- (void)requestContractWithAcbId:(NSString *)acbId contractType:(NSInteger)contractType cooperationType:(NSInteger)cooperationType success:(void (^)(NSArray *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"acbId":acbId,
                                 @"contract_type":@(contractType),
                                 @"cooperation_type":@(cooperationType)
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.22  (合作类型：1房源合作 2客源合作)%zd获取(合同类型：1居间合同 2买卖合同)%zd合同文件: responseObject-->%@",cooperationType,contractType,responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        if (successBlock) {
            if ([responseObject[@"data"] isKindOfClass:[NSArray class]]) {
                successBlock(responseObject[@"data"]);
            }
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.5.1 添加合作进度合作协议 (图文上传)
- (void)insertCooprationAgreementWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"saId":[SISSUserAccount shared].saId,
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_HOUSE_COOPPROGRESS_COOPERATION_CONTRACT parameters:params success:^(id responseObject) {
                NSLog(@"4.5.1 添加房源合作进度合作协议 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.5.2 跟新合作进度合作协议 (图文上传) PUT请求
- (void)updateCooprationAgreementWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"saId":[SISSUserAccount shared].saId,
                                            @"file":dataArr,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_HOUSE_COOPPROGRESS_COOPERATION_CONTRACT parameters:params success:^(id responseObject) {
                    NSLog(@"4.5.2 跟新合作进度合作协议 (图文上传) PUT请求): responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId":[SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_HOUSE_COOPPROGRESS_COOPERATION_CONTRACT parameters:params success:^(id responseObject) {
            NSLog(@"4.5.2 跟新合作进度合作协议 (图文上传) PUT请求): responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.8.1 添加房源合作带看记录 (图文上传)
- (void)insertHouseCooprationTakeLookWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [SISSPublicSingleton shared].isHud = NO;
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_HOUSE_COOP_TAKELOOK parameters:params success:^(id responseObject) {
                NSLog(@"4.8.1 添加房源合作带看记录 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.8.2 添加客源合作带看记录  (图文上传)
- (void)insertPassengerCooprationTakeLookWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [SISSPublicSingleton shared].isHud = NO;
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_PASSENGER_COOP_TAKELOOK parameters:params success:^(id responseObject) {
                NSLog(@"4.8.2 添加客源合作带看记录 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.21 上传合同  (图文上传)
- (void)uploadContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [kNetworkNoUTF8Manager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_UPLOAD_CONTRACT parameters:params success:^(id responseObject) {
                NSLog(@"4.21 上传合同 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.18.1 获取居间合同 GET请求
- (void)requestIntermediaryContractWithAbpId:(NSString *)abpId success:(void (^)(SISSIntermediaryContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"abpId": abpId,
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_COOP_MIDDLE_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.18.1 获取居间合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSDictionary *dataDict = responseObject[@"data"];
        SISSIntermediaryContractModel *model = [SISSIntermediaryContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.18.2 添加居间合同 (图文上传)
- (void)insertCoopMiddleContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSMutableArray *dataArrM = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"file":dataArrM,
                                        @"saId" : [SISSUserAccount shared].saId,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_COOP_MIDDLE_CONTRACTT parameters:params success:^(id responseObject) {
                NSLog(@"4.18.2 添加居间合同 (图文上传): responseObject-->%@",responseObject);
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.18.3 更新居间合同 (图文上传) PUT请求
- (void)updateCoopMiddleContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSMutableArray *dataArrM = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"file":dataArrM,
                                            @"saId" : [SISSUserAccount shared].saId,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_COOP_MIDDLE_CONTRACTT parameters:params success:^(id responseObject) {
                    NSLog(@"4.18.3 更新居间合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_COOP_MIDDLE_CONTRACTT parameters:params success:^(id responseObject) {
            NSLog(@"4.18.3 更新居间合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

// 4.19.1 获取买卖合同 GET请求
- (void)requestBusinesscontractWithAbpId:(NSString *)abpId success:(void (^)(SISSIntermediaryContractModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    NSDictionary *parameters = @{
                                 @"abpId":abpId
                                 };
    
    [kNetworkManager GETWithURLString:URL_PROGRESS_GET_COOP_BUSINESS_CONTRACT parameters:parameters success:^(id responseObject) {
        NSLog(@"4.19.1 获取买卖合同 GET请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        NSDictionary *dataDict = responseObject[@"data"];
        SISSIntermediaryContractModel *model = [SISSIntermediaryContractModel yy_modelWithJSON:dataDict];
        if (successBlock) {
            successBlock(model);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 4.19.2 上传买卖合同 (图文上传)
- (void)insertCoopBusinessContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
        NSLog(@"%@",responseObject);
        if ([responseObject[@"code"] integerValue] == 200) {
            NSArray *dataArr = responseObject[@"data"];
            NSDictionary *parameter = @{
                                        @"saId" : [SISSUserAccount shared].saId,
                                        @"file":dataArr,
                                        };
            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
            [params addEntriesFromDictionary:parameters];
            
            [kNetworkNoUTF8Manager POSTWithURLString:URL_PROGRESS_INSERT_COOP_BUSINESS_CONTRACTT parameters:params success:^(id responseObject) {
                NSLog(@"4.19.2 上传买卖合同 (图文上传): responseObject-->%@",responseObject);
                
                if ([responseObject[@"code"] integerValue] != 200) {
                    
                    NSLog(@"%@",responseObject[@"data"]);
                }
                
                if (successBlock) {
                    successBlock(responseObject);
                }
            } failure:^(NSError *error) {
                if (failedBlock) {
                    failedBlock(error);
                }
            }];
        }
    } failed:^(NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
}

// 4.19.3 更新买卖合同 (图文上传) PUT请求
- (void)updateCoopBusinessContractWithParameters:(NSDictionary *)parameters images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    if (images.count > 0) {
        
        [kNetworkManager uploadFileListWatermark:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameter = @{
                                            @"saId" : [SISSUserAccount shared].saId,
                                            @"file":dataArr,
                                            };
                NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
                [params addEntriesFromDictionary:parameters];
                
                [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_COOP_BUSINESS_CONTRACTT parameters:params success:^(id responseObject) {
                    NSLog(@"4.19.3 更新买卖合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
                    
                    if ([responseObject[@"code"] integerValue] != 200) {
                        
                        NSLog(@"%@",responseObject[@"data"]);
                    }
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameter = @{
                                    @"saId" : [SISSUserAccount shared].saId,
                                    };
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:parameter];
        [params addEntriesFromDictionary:parameters];
        
        [kNetworkNoUTF8Manager PUTWithURLString:URL_PROGRESS_UPDATE_COOP_BUSINESS_CONTRACTT parameters:params success:^(id responseObject) {
            NSLog(@"4.19.3 更新买卖合同 (图文上传) PUT请求: responseObject-->%@",responseObject);
            
            if ([responseObject[@"code"] integerValue] != 200) {
                
                NSLog(@"%@",responseObject[@"data"]);
            }
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
}

@end
